<?php

namespace app\home\controller;
use app\admin\model\Purchase as PurchaseModel;
class Purchase extends Base
{
    public function index()
    {
        $data=PurchaseModel::order('id','desc')->select();
        $id=$this->request->param('id');
        if ($id==null){
            $content=$data[0];
            $title=$data[0]['title'];
        }else{
            $content=PurchaseModel::where('id',$id)->find();
            $title=$content['title'];
        }
        $this->assign([
            'content'=>$content,
            'title'=>$title,
            'id'=>$id,
            'data'=>$data,
            'menu'=>'purchase',
        ]);
        return $this->fetch();
    }
}